<template>
  <div class="box">
    <!-- <div class="head-wrap">
      <Header/>
    </div> -->
    <div class="second-nav-wrap" :class="{'box-transition':hasTransition}" :style="{width:(navNum&&showSecondMenu?160:0)+'px'}">
      <SecondNav @hideSecond="hideSecond" v-show="navNum" :show="navNum&&showSecondMenu"/>
    </div>
    <div class="main-wrap" :class="{'box-transition':hasTransition}">
      <div class="main-header">
        <Header :show="navNum&&showSecondMenu" @hideSecond="hideSecond"/>
      </div>
      <div>
        <div class="main">
          <transition name="fade-transform" mode="out-in">
            <router-view/>
          </transition>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import Header from './components/header'
import SecondNav from './components/secondNav'
import { mapGetters } from 'vuex'
export default {
  components: {
    Header,
    SecondNav
  },
  data() {
    return {
      loadSecondMenu: true,
      showSecondMenu: false,
      breadcrumbZone: 136,
      hasTransition: false
    }
  },
  computed: {
    ...mapGetters([
      'navNum'
    ])
  },
  watch:{
    navNum(nval) {
      if (nval) {
        this.showSecondMenu = true
      }
    }
  },
  beforeMount() {
    this.navNum && (this.showSecondMenu = true)
    // this.showSecondMenu = true
  },
  mounted() {
    setTimeout(() => {
      this.hasTransition = true
    }, 500);
  },
  methods: {
    hideSecond() {
      this.showSecondMenu = !this.showSecondMenu 
    },
  }
}
</script>

<style lang="scss" scoped>
.box {
  display: flex;
  height: 100vh;
}
.head-wrap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
}
.box-transition {
  transition: all 0.3s;
}
.second-nav-wrap {
  // top: 72px;
  // bottom: 0;
  height: 100vh;
  z-index: 1;
  box-shadow:0px 5px 13px 0px rgba(37,36,36,0.1);
  .onoff {
    position: absolute;
    top: 50%;
    margin-top: -33px;
    right: -17px;
    width: 17px;
    height: 67px;
    background: #F4222D;
    border-radius: 0px 5px 5px 0px;
    cursor: pointer;
    &:after {
      content: '';
      width: 8px;
      height: 8px;
      border: 1px solid #fff;
      border-left: none;
      border-bottom: none;
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translateX(-2px) translateY(-50%) rotate(-135deg);
      transition: .2s;
    }
  }
  .s-hide {
    &:after {
      transform: translateX(-6px) translateY(-50%) rotate(45deg);
    }
  }
}
.main-wrap {
  // padding: 20px;
  overflow-y: auto;
  box-shadow: 0 5px 13px 0 rgba(37,36,36,.1);
  height: 100vh;
  flex: 1;
  display: flex;
  flex-direction: column;
  .main-header {
    height: 64px;
  }
  .main {
    height: calc(100vh - 64px);
    border-radius:10px;
    flex: 1;
    overflow-y: hidden;
    padding: 25px 31px 25px 31px;
    // height: 850px;
  }
}
.shop-time {
  // width: 842px;
  width: inherit;
  height: 38px;
  padding: 0 54px;
  background: rgba(255,98,94,1);
  border-radius: 0px 0px 10px 10px;
  color: #fff;
  position: fixed;
  top: 73px;
  left: 50%;
  font-size: 16px;
  text-align: center;
  transform: translateX(-50%);
  display: flex;
  justify-content: center;
  align-items: center;
  .buy-btn {
    line-height: 30px;
    font-size: 16px;
    color: #F4222D;
    background: #fff;
    width: 90px;
    border-radius:5px;
    text-align: center;
    margin-left: 20px;
  }
}
</style>